# -*- coding = utf-8
#@[Time] : 2021/4/1 8:42
#@Auther : xiahuaS
#@File : J-1.py
#@Software : PyCharm

import requests,pywasm,time,random,math

def get_wasm():
    pre_m = pywasm.load("main.wasm")
    time_data = time.time()
    t1= int(time_data/2)
    t2 = int(time_data/2-math.floor(random.randint(0,52)))
    m = pre_m.exec("encode",[t1,t2])
    wasm = str(m) +'|'+ str(t1) + '|'+ str(t2)
    return wasm

def get_data(index,wasm):
    url  = 'http://match.yuanrenxue.com/api/match/15?m=' + f'{wasm}' + '&page=' + f'{index}'
    headers = {
        'User-Agent':'yuanrenxue.project'
    }
    resp = requests.get(url,headers = headers)
    pre_data = resp.json()
    for i in range(len(pre_data['data'])):
        data = pre_data['data'][i]['value']
        values.append(data)

if __name__ == '__main__':
    values = []
    wasm = get_wasm()
    for index in range(1,6):
        get_data(index,wasm)

    print(sum(values))